package main

import "fmt"

// 变量初始化、赋值
func main() {

	changeTwoVariableWithTemp()
	fmt.Println()
	changeTwoVariableWithoutTemp()
	fmt.Println()
	anonymousVariable()

}

func changeTwoVariableWithTemp() {
	a, b := 10, 20
	fmt.Printf("a = %d b =%d  \n", a, b)
	var temp int
	temp = a
	a = b
	b = temp
	fmt.Printf("a = %d b =%d  \n", a, b)

}

func changeTwoVariableWithoutTemp() {
	a, b := "zs", "ls"
	fmt.Printf("前：a=%v b=%v \n", a, b)

	a, b = b, a
	fmt.Printf("后：a=%v b=%v \n", a, b)
}

func anonymousVariable() {
	var a, b, c int
	a, b, c = test()
	fmt.Printf("a=%d b=%d c=%d\n", a, b, c)

	var d int
	_, d, _ = test()
	fmt.Printf("d=%d\n", d)
}

// 一个函数 入参0个  返回3个值
func test() (c, d, e int) {
	return 1, 2, 3

}
